<?php

class person
{
    public $name;
    public $age;
    public $sex;

    public function __construct($name,$age,$sex)
    {
        $this->name=$name;
       $this->age=$age;
       $this->sex=$sex;
    }

    public function say(){
        echo '我的名字是'.$this->name.',我的性别是'.$this->sex.',我的年龄是'.$this->age;
    }
    public function __set($name, $value)
    {
        if($name=='age'){
            $this->age(($value<0)?1:$value);
        }
        $this->name=$value;
    }
}

$my=new person();
$my->age=36;
$my->sex='男';
$my->name='chen';

$my->say();

?>